---
layout: default
title: Profiles
permalink: /profiles/
redirect_from:
  - /profiles.html
sitemap:
    priority: 0.7
    lastmod: 2014-11-26T00:00:00-00:00
---

<h1><i class="fa fa-group"></i> Profiles</h1>

<p>
JHipster comes with two <a href="http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html">Spring profiles</a> :
</p>

<ul>
  <li><code>dev</code> for development: it focuses on ease of development and productivity</li>
  <li><code>prod</code> for production: it focuses on performance and scalability</li>
</ul>

<p>
Those profiles come in two different configurations:
</p>

<ul>
  <li>The Maven/Gradle profiles are used at build time. For example <code>./mvnw -Pprod package</code> or <code>./gradlew bootRepackage -Pprod</code> will package a production application.</li>
  <li>The Spring profiles work at run time. Some Spring beans will behave differently, depending on the profile.</li>
</ul>

<p>
Spring profiles are set by Maven/Gradle, so we have a consistency between the two methods: you will have a <code>prod</code> profile on Maven/Gradle and Spring at the same time.
</p>

<h2>
By default, JHipster will use the <code>dev</code> profile
</h2>
<p>
    If you run the application without Maven/Gradle, launch the "Application" class (you can probably run it easily from your IDE by right-clicking on it).
<p>
<p>
    If you run the application with Maven, run <code>./mvnw</code> to use our Maven Wrapper, or <code>mvn</code> to use your own Maven installation.
</p>
<p>
    If you run the application with Gradle, run <code>./gradlew</code> to use our Gradle Wrapper, or <code>gradle</code> to use your own Gradle installation.
</p>

<h2>
In production, JHipster has to run with the <code>prod</code> profile
</h2>
<p>
    You can run JHipster in production directly using Maven or Gradle:
</p>
<ul>
    <li>With Maven, run <code>./mvnw -Pprod</code> (or <code>mvn -Pprod</code>)</li>
    <li>With Gradle, run <code>./gradlew -Pprod</code> (or <code>gradle -Pprod</code>)</li>
</ul>
<p>
    If you want to package your application as an executable WAR file, you should provide Maven or Gradle with a profile. E.g.,:
</p>
<ul>
    <li>With Maven, run <code>./mvnw -Pprod package</code> (or <code>mvn -Pprod package</code>)</li>
    <li>With Gradle, run <code>./gradlew -Pprod bootRepackage</code> (or <code>gradle -Pprod bootRepackage</code>)</li>
</ul>

<p>
    When you run your production application from a WAR file, the default is to use the same profile(s) as used during packaging.
    If you want to override this, you can explicitly provide an alternative in VM argument:
</p>
<ul>
    <li><code>./java -jar jhipster-0.0.1-SNAPSHOT.war --spring.profiles.active=...</code></li>
</ul>

<h2>
Spring profiles switches
</h2>
<p>
JHipster comes with two additional Spring "profiles" used as switches:
</p>
<ul>
  <li><code>swagger</code> to enable swagger</li>
  <li><code>no-liquibase</code> to disable liquibase</li>
</ul>
<p>These can be used along with both the <code>dev</code> and <code>prod</code> profiles.
Please note that by default, the <code>swagger</code> profile is disabled in <code>prod</code> and enabled in <code>dev</code> by setting the <code>spring.profiles.include</code> property in <code>application-dev.yml</code>.
<p>They are only used at runtime:</p>

<ul>
    <li>In your IDE, run your main application class with <code>spring.profiles.active=dev,no-liquibase</code> (please note you need to include the <code>dev</code> or <code>prod</code> profile explicitly)</li>
    <li>With a packaged application: <code>./java -jar jhipster-0.0.1-SNAPSHOT.war --spring.profiles.active=prod,no-liquibase</code></li>
</ul>

<p>With Maven, you can also use those profiles directly:<p>

<ul>
    <li><code>./mvnw -Pprod,swagger,no-liquibase</code></li>
    <li><code>./mvnw -Pdev,no-liquibase</code></li>
</ul>

<p>With Gradle, you can also use those profiles directly:<p>

<ul>
    <li><code>./gradlew -Pprod -Pswagger -Pno-liquibase</code></li>
    <li><code>./gradlew -Pno-liquibase </code></li>
</ul>
